package org.example.controller;

import jakarta.annotation.Resource;
import org.example.po.CommonResult;
import org.example.po.Food;
import org.example.service.FoodService;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RefreshScope
@RestController
@RequestMapping("/Food")
public class FoodController {

    @Resource
    private FoodService foodService;

    @GetMapping("/BusinessId/{businessId}")
    public CommonResult<List> listFoodByBusinessId(@PathVariable("businessId") Integer businessId) throws Exception {
        List<Food> list = foodService.listFoodByBusinessId(businessId);
        return new CommonResult<List>(200, "success", list);
    }
    @PostMapping("/Save")
    public CommonResult<Food> saveFood(Food food){
        int result = foodService.saveFood(food);
    return new CommonResult<Food>(200,"success",food);
    }
}
